﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeiTap.Data.TransactionManager;

namespace WeiTap.Data.Core
{
    public interface IDatabase:IDisposable,IQuery,IExecute,ITransactionAccessor
    {
        IMapper DefaultMapper { get; }
        string LastSql { get; }
        object[] LastArgs { get; }
        string LastCommand { get; }
        /// <summary>
        ///当调用查询的时候是否自动生成查询语句，默认为true
        /// </summary>
        bool EnableAutoSelect { get; set; }
        /// <summary>
        /// 自动生成格式化参数格式：@param1
        /// </summary>
        bool EnableNamedParams { get; set; }
        /// <summary>
        /// 值为0，则采用默认时间30S
        /// </summary>
        int CommandTimeout { get; set; }
        /// <summary>
        /// 为下一条执行语句设置超时时间，只能使用一次
        /// </summary>
        int OneTimeCommandTimeout { get; set; }
        IProvider Provider { get; }
        string ConnectionString { get; }
        /// <summary>
        /// 设置数据库的锁定行为，不设置则为默认值
        /// </summary>
        IsolationLevel? IsolationLevel { get; set; }
        /// <summary>
        /// using(var tx=db.GetTransaction())
        /// {
        ///     db.Update(....);
        ///     tx.Complete();
        /// }
        /// </summary>
        /// <returns></returns>
        ITransaction GetTransaction();
        void BeginTransaction();
        void AbortTransaction();
        void CompleteTransaction();
    }
}
